<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <table>
            <tr v-for="user in userList">
                <td>
                    {{user.name}}--{{user.age}}
                </td>
            </tr>
        </table>

    </div>
    <script src="vue.min.js"></script>
    <script src="axios.min.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                userList: []
            },
            created() {
                //在页面渲染之前，调用方法得到返回的json数据
                this.getList()
            },
            methods: {
                getList() {
                    //使用axios方式ajax请求
                    axios.get("user.json") //请求的接口路径
                        .then(Response => {
                            this.userList = Response.data.data.items
                            console.info(this.userList)
                        }) //请求成功
                        .catch(error => {
                            console.info(error)
                        }) //请求失败
                }
            }
        })
    </script>
</body>

</html>